<!--
	作者：956911785@qq.com
	时间：2019年11月21日17:04:33
	描述：账号搜索
-->
<template>
    <div style="width:100%;"> 
        <Tetable ref="tdtable" height="450" :columns="columns9" type="post" :paramiters="tj" :serverUrl="serverUrl"></Tetable>
		<edit ref="edit" @reload="load" :editparams="editparams"></edit>
	</div> 
</template>
<script>
	import EditDelLook from "./EditDelLook";
	import edit from "./edit";
    export default {
    	name: "uaccountss",
    	props: {
    		tj:{
    			type: Object
    		}
    	},
		components: {
			EditDelLook,
			edit
		},
        data () {
            return {
            	serverUrl:"/host/readbook/uaccount/Search_uaccount.html",
                columns9: [
                    {
                        type: 'index',
                        width: 60,
                        title: '序号',
                        align: 'center'
                    },{
                        title: '角色',
                        key: 'WSTATET',
                        align: 'center'
                    },{
                        title: '姓名',
                        key: 'NAME',
                        align: 'center',
                    },{
                        title: '性别',
                        key: 'SEX',
                        align: 'center'
                    },{
                        title: '职位',
                        key: 'ZW',
                        align: 'center'
                    },{
                        title: '年级',
                        key: 'NJ',
                        align: 'center'
                    },{
                        title: '班级',
                        key: 'BJ',
                        align: 'center'
                    },{
                        title: '账号',
                        key: 'DLZH',
                        align: 'center'
                    }, {
                        title: '操作',
                        key: 'action',
                        width: 200,
                        align: 'center',
                        render: (h, params) => {
                            return h(EditDelLook, {
                            	on: {
                                    //修改账号
                                    edit: () => {
                                    	const rows=params.row;
                                    	var usid="";
                                    	if(rows.USID){
                                    		usid=rows.USID;
                                    	}
                                    	var dlzh="";
                                    	if(rows.DLZH){
                                    		dlzh=rows.DLZH;
                                    	}
										
										var name="";
										if(rows.NAME){
											name=rows.NAME;
										}
										
										var wstate="";
										if(rows.WSTATE){
											wstate=rows.WSTATE;
										}
										
										var sex="";
										if(rows.SEX){
											sex=rows.SEX;
										}
										
										var zw="";
										if(rows.ZW){
											zw=rows.ZW;
										}
										
                                    	var nj="";
                                    	if(rows.NJ){
                                    		nj=rows.NJ;
                                    	}
                                    	var bj="";
                                    	if(rows.BJ){
                                    		bj=rows.BJ;
                                    	}
										
										var year="";
										if(rows.YEAR){
											year=rows.YEAR;
										}
                                    
                                    	this.editparams={
                                    		usid:usid,
                                    		dlzh:dlzh,
                                    		name:name, 
                                    		wstate:wstate+"", 
                                    		sex:sex, 
                                    		zw:zw,
                                    		nj:nj,
                                    		bj:bj,
                                    		year:year
                                    	}
                                        this.$refs.edit.openmodal();
                                    },
                                    //删除账号
                                    remove: () =>{
										const rows=params.row;
										if(this.user.uname=='admin'){
											this.remove(rows.USID)
										}else{
											this.$Modal.error({
											    title: "提示",
											    content:'对不起，您没有此权限！'
											});
										}
                                    }, 
                                }
                            });
                        }
                    }
                ],
				
				editparams:{},
            }
        },
        computed: {
        	user: function() {
        		return this.$store.state.app.user;
        	}
        },
		methods: {
			load(){
				this.$refs.tdtable.load();
			},
			
			//删除账号
			remove:function(usid){
			    this.$Modal.confirm({
			        title: '警告',
			        content: '请确定是否删除！！！',
			        onOk: () => {
			        	//执行删除代码
			        	this.$http.get("/host/readbook/uaccount/del_uaccount.html?usid="+usid)
						.then(datas => {
							if(datas.result){
								//删除成功 刷新页面
								this.$Message.info('删除成功');
								this.$refs.tdtable.load();
							}else{
								//删除成功 刷新页面
								this.$Message.info(datas.msg);
								this.$refs.tdtable.load();
							}
							
						});
			        }
			    });
			},
	    },
		mounted() {
		},
		watch:{
		},
    }
</script>


<style scoped="scoped">
	
	.ivu-table-wrapper {
		border:none;
	}
	
	.toolstipdiv{
		width: '100%';
		overflow: 'hidden';
		textOverflow: 'ellipsis';
		whiteSpace: 'normal';
		wordBreak: 'break-all';
		color:'#fff';
		text-align: center;
	}
	.toolstipdiv:hover{
		background:rgb(63, 193, 201);
	}
	
	.ivu-tooltip-rel label:hover{
		color:#0023FB;
	}
	
	.tablediv{
		height: '40px';
		overflow:'hidden';
		line-height: '40px';
	}
</style>



